//spu模块的接口函数
import request from '@/utils/request';

//获取某一个三级分类的全部SPU
export const reqFindSpuInfo = (page,limit,category3Id)=>request({url:`/admin/product/${page}/${limit}?category3Id=${category3Id}`,method:'get'});


//通过SPU的ID获取SPU详情的接口
export const reqFetchSpuInfo = (spuId)=>request({url:`admin/product/getSpuById/${spuId}`,method:'get'});

//获取品牌的数据
export const reqFetchTradeMark = ()=>request({url:`/admin/product/baseTrademark/getTrademarkList`,method:'get'});

//获取某一个SPU照片墙的接口
export const reqSpuImageList = (spuId)=>request({url:`/admin/product/spuImageList/${spuId}`,method:'get'});

//获取项目全部销售属性：颜色、版本、尺码
export const reqAllSaleAttr = ()=>request({url:`/admin/product/baseSaleAttrList`,method:'get'});


//添加或者修改SPU的接口
export const reqAddOrUpdateSpu = (data)=>{
      //参数携带ID修改已有的SPU
      if(data.id){
         return request({url:`/admin/product/updateSpuInfo`,method:'post',data})
      }else{
       //新增
       return request({url:`/admin/product/saveSpuInfo`,method:'post',data})
      }
}


//获取SPU销售属性接口
export const reqSaleAttrList = (spuId)=>request({url:`/admin/product/spuSaleAttrList/${spuId}`,method:'get'});

//获取平台属性
export const reqAttrList =(category1Id,category2Id,category3Id)=>request({url:`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,method:'get'});


//添加SKU的接口
export const reqAddSku = (data)=>request({url:'/admin/product/saveSkuInfo',method:'post',data})


//查看全部的实例SKU
export const reqSkuList = (spuId)=>request({url:`/admin/product/findBySpuId/${spuId}`,method:'get'});


//删除SPU接口
export const reqDeleteSpu = (spuId)=>request({url:`/admin/product/deleteSpu/${spuId}`,method:'delete'});